//
//  DiscoverViewController.swift
//  上海微博
//
//  Created by apple on 16/5/11.
//  Copyright © 2016年 kuaikuaipao. All rights reserved.
//

import UIKit
private let CZDiscoverCellID = "CZDiscoverCellID"
class DiscoverViewController: RootViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
       
        //
        tableview.registerClass(UITableViewCell.self, forCellReuseIdentifier: CZDiscoverCellID)
        
    }
    override func loadData() {
        //
        
        refreshControl.beginRefreshing()
        
        let when = dispatch_time(DISPATCH_TIME_NOW, Int64(Double(NSEC_PER_MSEC) * 1.0))
        
        dispatch_after(when, dispatch_get_main_queue()) { () -> Void in
            
            
            self.dataCount += 10
            
            // 结束刷新
            self.refreshControl.endRefreshing()
            self.pullupView.stopAnimating()
            
            self.tableview.reloadData()
        }
    
        
    }
    
    

 //私有属性
private var dataCount = 0
    
}

extension DiscoverViewController {
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return dataCount
    }
    
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
          let cell  = tableview.dequeueReusableCellWithIdentifier(CZDiscoverCellID, forIndexPath: indexPath)
          cell.textLabel?.text = "\(indexPath.row)"
        return cell
        
    }
    
    
}